package com.gome.controller;


import com.gome.entitiy.Ryxx;
import com.gome.utils.Result;
import org.apache.log4j.Logger;
import org.springframework.security.core.Authentication;

import javax.servlet.http.HttpServletRequest;

public class BaseController {
    protected final Logger logger=Logger.getLogger(this.getClass());

    public Result buildResult(String resultCode, Object data, String message) {
        return   new Result(resultCode, message, data);
    }

    public String getUserName(HttpServletRequest req){
        Authentication auth = (Authentication)req.getSession().getAttribute("SPRING_SECURITY_CONTEXT");
        Ryxx ryxx = (Ryxx)auth.getPrincipal();
        return ryxx.getOc_loginname();
    }
    public Ryxx getUser(HttpServletRequest req){
        Authentication auth = (Authentication)req.getSession().getAttribute("SPRING_SECURITY_CONTEXT");
        Ryxx ryxx = (Ryxx)auth.getPrincipal();
        return ryxx;
    }


}
